package com.yzk.train.common.response;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> implements Serializable {

    // 响应状态
    private Boolean status = true;
    // 响应消息
    private String message;
    // 响应数据
    private T content;

    public static <T> Result<T> ok(Boolean status, String message, T content) {
        return new Result<>(status, message, content);
    }

    public static <T> Result<T> ok(String message, T content) {
        return new Result<>(true, message, content);
    }

    public static <T> Result<T> okMessage(String message) {
        return new Result<>(true, message, null);
    }

    public static <T> Result<T> ok(T content) {
        return new Result<>(true, "成功", content);
    }

    public static <T> Result<T> fail(String message) {
        return new Result<>(false, message, null);
    }

}
